package com.chazz.servlet;

import com.chazz.Do.GoodsDetailsInfo;
import com.chazz.service.impl.GoodsInfoServiceImpl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 描述:响应商品详情信息请求的servlet
 *
 * @author Chazz
 * @create 2020-09-24 19:12
 */
@WebServlet("/goodsInfo.do")
public class GoodsInfoServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
        Integer goodsId = Integer.parseInt(req.getParameter("goodsId").trim());
        GoodsDetailsInfo goodsDetailsInfo = new GoodsInfoServiceImpl().sutureCommodityInformation(goodsId);
        System.out.println(goodsDetailsInfo);
        req.setAttribute("goodsInfo",goodsDetailsInfo);
        req.getRequestDispatcher("/single1.jsp").forward(req, resp);
    }
}
